//
//  XQOrderDetailTopView.swift
//  Spark Peso
//
//  Created by 小琦 on 2025/2/4.
//

import UIKit

class XQOrderDetailTopView: UIView {
    
    var model : XQOrderDetailIncreasingModel? {
        didSet {
            self.titleLb.text = model?.currently
            self.dollorLb.text = model?.governments
            self.termView.top = model?.schools?.integrated?.accessing
            self.termView.bottom = model?.schools?.integrated?.board
            self.rateView.top = model?.schools?.ruled?.accessing
            self.rateView.bottom = model?.schools?.ruled?.board
        }
    }

    private lazy var bgImageView : UIImageView = {
        let imageView = UIImageView()
        imageView.image = UIImage(named: "detail_bg")
        return imageView
    }()
    
    private lazy var titleLb : UILabel = {
        let lb = UILabel()
        lb.textColor = .xq_black
        lb.font = UIFont.systemFont(ofSize: 14)
        return lb
    }()
    
    private lazy var dollorLb : UILabel = {
        let lb = UILabel()
        lb.textColor = .xq_black
        lb.font = UIFont.systemFont(ofSize: 40, weight: .medium)
        return lb
    }()
    
    private lazy var termView : XQOrderDetailTopUpOrDownView = {
        let view = XQOrderDetailTopUpOrDownView()
        return view
    }()
    
    private lazy var rateView : XQOrderDetailTopUpOrDownView = {
        let view = XQOrderDetailTopUpOrDownView()
        return view
    }()
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.isUserInteractionEnabled = true
        makeUI()
        makeConstraints()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        makeUI()
        makeConstraints()
    }
    
    private func makeUI() {
        self.addSubview(self.bgImageView)
        self.addSubview(self.titleLb)
        self.addSubview(self.dollorLb)
        self.addSubview(self.termView)
        self.addSubview(self.rateView)
    }
    
    private func makeConstraints() {
        self.bgImageView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
        self.titleLb.snp.makeConstraints { make in
            make.top.equalTo(54)
            make.left.equalTo(40)
        }
        self.dollorLb.snp.makeConstraints { make in
            make.left.equalTo(self.titleLb.snp.left)
            make.top.equalTo(self.titleLb.snp.bottom)
            make.height.equalTo(56)
        }
        self.termView.snp.makeConstraints { make in
            make.bottom.equalTo(-16)
            make.left.equalTo(40)
            make.width.equalTo(100)
        }
        self.rateView.snp.makeConstraints { make in
            make.centerY.equalTo(self.termView)
            make.left.equalTo(200)
            make.right.equalTo(-12)
        }
    }
    

}
